
<?php $this->beginBlock('css');?>
  <link rel="stylesheet" type="text/css" href="<?= Yii::getAlias('@static')?>/pc/liketry/css/shop.css">
<?php $this->endBlock();?>

<?= $this->render('@liketry/views/layouts/header_shop.php',['step'=>1])?>

<div class="main">
 <?php if(!empty($data)):?>
  <div class="shop-main">
    <div class="shop-content">
      <div class="shop-title">
        <div class="shop-select"><span class="icon icon-stock"></span></div>
        <div class="shop-image">商品</div>
        <div class="shop-name">商品名称</div>
        <div class="shop-size">规格</div>
        <div class="shop-price">单价</div>
        <div class="shop-amount">数量</div>
        <div class="shop-sum">金额小计</div>
        <div class="shop-do">操作</div>
      </div>
      <div class="shop-list">
        <ul>
        <?php if(!empty($fullcut)):?><li><div class="shop-discount"><em>满减</em><i id="fullcut"><?=$fullcut;?></i></div></li><?php endif;?>
        <?php
            foreach ($data as $key=>$item) {
               $url = $item['status'] == true ? Yii::$app->urlManager->createUrl(['goodsdetail/index','product_id'=>$item['product_id']]) : 'javascript:void(0)';
        ?>
        <li class="<?php if(!$item['status']) echo 'dis';?>" data-cart-id="<?=$item['cart_id'];?>" data-product-id="<?=$item['product_id'];?>">
            <div class="shop-select">
            	<?php if($item['status']):?>
            	<span class="icon icon-stock"></span>
            	<?php else :?>
            	<span class="icon icon-purple-dis">失效</span>
            	<?php endif;?>
            </div>
            <div class="shop-image"><a target="_blank" href="<?=$url;?>"><img src="<?=$item['pic']?>"></a></div>
            <div class="shop-name">
              <p><a  target="_blank"  href="<?=$url;?>"><?=$item['goods_name'];?></a></p>
              <div class="shop-tags"><span class="icon icon-purple"><?=$item['type_name'];?></span>
              <?php if($item['free_post'] == 1):?> <span class="icon icon-purple">免邮</span><?php endif;?>
			  </div>
            </div>
            <div class="shop-size">
               <?php if(empty($item['spec_desc'])):?>
                    <span class="size-name">&nbsp;</span>
                    <span class="size-value"></span>
               <?php else:foreach ($item['spec_desc'] as $specval):?>
                	 <span class="size-name"><?=$specval['name'];?>:</span>
                    <span class="size-value"><?=$specval['value'];?></span>
                <?php 
            	    endforeach;endif;
                ?>
            </div>
            
            <div class="shop-price">
            	 <?php if ($item['price_type'] == 0):?>
                 <span class="price-rmb">￥<?=$item['price'];?></span>
                 <?php else:?>
                 <span class="price-sd"><?=$item['price'];?>试豆</span> 
                 <?php endif;?>
             </div>
            <div class="shop-amount">
              <div class="amount-edit">
              <?php if($item['status']):?>
                <span class="amount-reduce">-</span>
                <input class="amount-input" type="text" value="<?=$item['number']?>" size="<?=$item['size']?>">
                <span class="amount-add">+</span>
                 <?php else :?>
                 <?php echo $item['number']; endif;?>
             </div>
            
            </div>
            <div class="shop-sum">
       		 <?php if ($item['price_type'] == 0):?>
            	 <span class="sum-rmb">￥<?=$item['totoal_price'];?></span>
             <?php else:?>
             	<span class="sum-sd"><?=$item['totoal_price'];?>试豆</span> 
             <?php endif;?>
             </div>
            <div class="shop-do"><span class="shop-del">删除</span></div>
          </li>
       <?php
            }
        ?>
        </ul>
      </div>
      <div class="settlement-wrap">
      	<div class="settlement fixbottom">
            <div class="settlement-in">
                <div class="settlement-do left"><span class="settlement-selectall"><span class="icon icon-stock"></span>全选</span><span class="settlement-del">删除所选商品</span><a href="<?=Yii::$app->urlManager->createUrl('index/index');?>" class="shop-more">继续购物</a></div>
                <div class="settlement-btn right" id="settlementBtn">去结算</div>
                <div class="settlement-info right">
                  <p><span class="settlement-selected">已选择<i>0</i>件商品</span><span>总价（不包含邮费）：<i class="settlement-sum-rmb">￥0.00</i> + <i class="settlement-sum-sd">0</i>试豆</span></p>
                  <p>已节省：-<i id="reduceAmount">¥0.00</i></p>
                </div>
            </div>
          </div>
      </div>
    </div>
  </div>
  <form id="cartForm" method="post" action="<?=Yii::$app->urlManager->createUrl('order');?>">
  <input name="_csrf" type="hidden" id="_csrf">
  <input type="hidden" name="cart_ids">
  </form>
  <?php endif;?>
  <div class="shop-none" <?php if(empty($data)) { echo 'style="display:block;"';}?> >
    <div class="shop-none-tips"><span class="icon icon-shopcart"></span><span class="shop-none-text">您的购物车空空如也<br>
      赶紧来挑几件干货吧</span></div>
    <div class="shop-none-btn"><a href="<?=Yii::$app->urlManager->createUrl('index/index');?>" class="icon icon-btn2">去逛逛 >></a></div>
  </div>
</div>

<?php $this->beginBlock('js');?>
<script src="<?= Yii::getAlias('@static')?>/pc/common/js/jquery-1.12.3.min.js"></script> 
<script src="<?= Yii::getAlias('@static')?>/pc/common/js/lkt.pc.js"></script> 
<script src="<?= Yii::getAlias('@static')?>/pc/liketry/js/cart.js"></script>
<script>
var cartDelUrl = "<?=Yii::$app->urlManager->createUrl('cart/del-cart');?>";
var changeNumUrl = "<?=Yii::$app->urlManager->createUrl('cart/change-num');?>";
var selectUrl = "<?=Yii::$app->urlManager->createUrl('cart/select-sum');?>";
var settleCartUrl = "<?=Yii::$app->urlManager->createUrl('order/cart-validate');?>";
var fullcut = "<?=$fullcut;?>";
</script>

<?php $this->endBlock();?>
